package io.lkt.modules.sys.controller;

import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;

import io.lkt.common.validator.ValidatorUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.lkt.modules.sys.entity.BBusinessLecturerEntity;
import io.lkt.modules.sys.service.BBusinessLecturerService;
import io.lkt.common.utils.PageUtils;
import io.lkt.common.utils.R;



/**
 * 商学院讲师信息表
 *
 * @author xss
 * @email dustwas@163.com
 * @date 2020-10-23 18:17:52
 */
@RestController
@RequestMapping("/sys/bbusinesslecturer")
public class BBusinessLecturerController {
    @Autowired
    private BBusinessLecturerService bBusinessLecturerService;

    /**
     * 列表
     */
    @RequestMapping("/list")
//    @RequiresPermissions("sys:bbusinesslecturer:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = bBusinessLecturerService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 列表
     */
    @RequestMapping("/queryAll")
//    @RequiresPermissions("sys:bbusinesslecturer:queryList")
    public R queryAll(){
        List<BBusinessLecturerEntity> businessLecturer = bBusinessLecturerService.queryAll();

        return R.ok().put("businessLecturer", businessLecturer);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
//    @RequiresPermissions("sys:bbusinesslecturer:info")
    public R info(@PathVariable("id") Integer id){
        BBusinessLecturerEntity bBusinessLecturer = bBusinessLecturerService.getById(id);

        return R.ok().put("bBusinessLecturer", bBusinessLecturer);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
//    @RequiresPermissions("sys:bbusinesslecturer:save")
    public R save(@RequestBody BBusinessLecturerEntity bBusinessLecturer){

        bBusinessLecturer.setCreateTime(new Date());
        bBusinessLecturer.setUpdateTime(new Date());
        bBusinessLecturerService.save(bBusinessLecturer);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
//    @RequiresPermissions("sys:bbusinesslecturer:update")
    public R update(@RequestBody BBusinessLecturerEntity bBusinessLecturer){
        ValidatorUtils.validateEntity(bBusinessLecturer);

        bBusinessLecturer.setUpdateTime(new Date());
        bBusinessLecturerService.updateById(bBusinessLecturer);
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
//    @RequiresPermissions("sys:bbusinesslecturer:delete")
    public R delete(@RequestBody Integer[] ids){
        bBusinessLecturerService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }

}
